<template>
    <section>
        <!--工具条-->

        <div class="section-content clearfix">
            <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
                <el-form :inline="true" :model="filters">
                    <el-form-item style="float: left;">
                        <el-input v-model="filters.name" placeholder="模板名称" @keyup.enter.native="getUsers()"></el-input>
                    </el-form-item>
                    <el-form-item class="tool-bt">
                        <el-button :type="buttonColor" v-on:click="getUsers">查询</el-button>
                    </el-form-item>
                    <el-form-item v-if="menubt.indexOf('/alarm_trigger_template/post')>-1">

                        <router-link to="/alarms/triggers/add">
                            <el-button :type="buttonColor">新增</el-button>
                        </router-link>
                    </el-form-item>
                </el-form>
            </el-col>

            <!--列表-->
            <el-table :data="query" class="alarmshistory" highlight-current-row v-loading="listLoading" :header-row-style="{backgroundColor: titleColor}" @selection-change="selsChange" style="width: 100%;">
                <el-table-column type="selection">
                </el-table-column>
                <el-table-column type="index" label="序号"  width="80":index="indexMethod">
                </el-table-column>
                <el-table-column prop="name" align="center" label="模板名称">
                </el-table-column>
                <el-table-column prop="customContent" align="center" label="告警触发推送内容">
                </el-table-column>
                <el-table-column prop="customContentNormal" align="center" label="告警解除推送内容" width="220">
                </el-table-column>
                <el-table-column label="备注" align="center" prop="remark">
                </el-table-column>
                <el-table-column prop="createTime" align="center" label="创建时间">
                </el-table-column>
                <el-table-column prop="updateTime" align="center" label="更新时间">
                </el-table-column>
                <el-table-column align="center" label="操作">
                    <template scope="scope">
                        <i v-if="menubt.indexOf('/alarm_trigger_template/put')>-1" @click="handleEdit(scope.$index, scope.row)"
                            title="编辑" icon="el-icon-edit" circle class="pb-icon icon-edit"></i>
                        <i v-if="menubt.indexOf('/alarm_trigger_template/delete')>-1" @click="handleDel(scope.$index, scope.row)"
                            icon="el-icon-delete" circle title="删除" class="pb-icon icon-delete"></i>
                        <i class="el-icon-download" style="font-size:30px;cursor:pointer;color:#0099cc;" title="模板下载" @click="tableToExcel(scope.$index,scope.row)"></i>
                    </template>
                </el-table-column>
            </el-table>

            <!--工具条-->
            <el-col :span="24" class="toolbar">
                <el-button v-if="menubt.indexOf('/alarm_trigger_template/delete')>-1" type="danger" @click="batchRemove"
                    :disabled="this.sels.length===0">批量删除</el-button>
                <el-pagination layout="prev, pager, next" @current-change="handleCurrentChange" :page-size="10" :total="total"
                    style="float:right;">
                </el-pagination>
            </el-col>
        </div>
        <!--编辑界面-->
        <el-dialog title="编辑" v-show="editFormVisible" v-model="editFormVisible" :custom-class="dialogTitleColor" @close="editFormVisible=false">
            <div slot="footer" style="text-align: left; ">
                <el-form :model="editForm" label-width="130px" :rules="editFormRules" ref="editForm">
                    <el-form-item label="告警点名称" class="grade" prop="name">
                        <el-input v-model="editForm.name"></el-input>
                    </el-form-item>
                    <el-form-item label="告警类型">
                        <el-select v-model="editForm.alarmTypeId" placeholder="请选择告警类型">
                            <el-option v-for="item in alarmtype" :label="item.name" :value="item.id"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="设备类型" class="grade" prop="deviceTypeId">
                        <el-select v-model="editForm.deviceTypeId" placeholder="请选择设备类型">
                            <el-option v-for="item in typelist" :label="item.name" :value="item.id"></el-option>
                        </el-select>
                    </el-form-item>
                    <!-- <el-form-item label="数据配方" class="grade">
                        <el-select v-model="editForm.deviceDataRecipeId" placeholder="请选择数据配方" @change="scade()">
                            <el-option v-for="item in device_data" :label="item.name" :value="item.id"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="数据配方数据点" class="grade">
                        <el-select v-model="editForm.deviceDataRecipeBodyId" placeholder="请选择数据配方数据点">
                            <el-option v-for="item in device_datalist" :label="item.name" :value="item.id"></el-option>
                        </el-select>
                    </el-form-item> -->
                    <el-form-item label="告警等级" class="grade">
                        <el-select v-model="editForm.level" placeholder="请选择告警等级">
                            <el-option v-for="item in alaem_grade" :label="item.remark" :value="item.value"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="数据点" class="grade">
                        <el-input v-model="editForm.register"></el-input>
                    </el-form-item>
                    <!-- <el-form-item label="触发条件" class="grade">
                        <el-select v-model="editForm.triggerCondition">
                            <el-option v-for="item in unitlist" :label="item.remark" :value="item.value"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="触发最小值" class="grade">
                        <el-input v-model="editForm.inputMin"></el-input>
                    </el-form-item>
                    <el-form-item label="触发最大值" class="grade">
                        <el-input v-model="editForm.inputMax"></el-input>
                    </el-form-item> -->
                    <el-form-item label="触发条件" class="grade" prop="triggerCondition">
                        <el-select v-model="editForm.triggerCondition" @change="Condition()">
                            <el-option v-for="item in unitlist" :label="item.remark" :value="item.value"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="触发A值" class="grade" prop="inputMin" >
                        <el-input type="number" v-model="editForm.inputMin" :disabled="editFormRules.inputMin.length==0"></el-input>
                    </el-form-item>
                    <el-form-item label="触发B值" class="grade" prop="inputMax">
                        <el-input type="number" v-model="editForm.inputMax" :disabled="editFormRules.inputMax.length==0"></el-input>
                    </el-form-item>
                    <el-form-item label="告警方式">
                        <el-radio-group v-model="editForm.alarmMode">
                            <el-radio label="1">微信</el-radio>
                            <el-radio label="2">短信</el-radio>
                            <!-- <el-radio label="3">邮件</el-radio> -->
                        </el-radio-group>
                    </el-form-item>
                    <!-- <el-form-item label="是否存储数据" class="grade">
                        <el-radio-group v-model="editForm.isSave">
                            <el-radio label="0">否</el-radio>
                            <el-radio label="1">是</el-radio>
                        </el-radio-group>
                    </el-form-item> -->
                    <!-- <el-form-item label="启用状态" class="grade">
                        <el-radio-group v-model="editForm.status">
                            <el-radio label="0" value="0">不启用</el-radio>
                            <el-radio label="1" value="1">启用</el-radio>
                        </el-radio-group>
                    </el-form-item> -->
                    <el-form-item label="告警触发推送内容">
                        <el-input type="textarea" v-model="editForm.customContent"></el-input>
                    </el-form-item>
                    <el-form-item label="告警解除推送内容">
                        <el-input type="textarea" v-model="editForm.customContentNormal"></el-input>
                    </el-form-item>
                    <el-form-item label="备注">
                        <el-input type="textarea" v-model="editForm.remark"></el-input>
                    </el-form-item>

                    <!-- <el-form-item label="告警人/组">
                        <el-transfer v-model="alarmUserList" :data="userlist" style="margin-left:30px;padding-bottom:20px;"></el-transfer>
                    </el-form-item> -->
                </el-form>
                <div slot="footer" class="dialog-footer" style="text-align:right;">
                    <el-button @click.native="editFormVisible = false">取消</el-button>
                    <el-button :type="buttonColor" @click.native="editSubmit" :loading="editLoading">提交</el-button>
                </div>
            </div>
        </el-dialog>

        <!--新增界面-->

    </section>
</template>

<script>
    // import util from './../common/js/util'
    //import NProgress from 'nprogress'
    import {
        alarm_group_query,
        alarms_query_user,
        alarm_trigger_get,
        alarm_trigger_delete,
        alarm_trigger_template_query,
        alarm_trigger_template_delete,
        alarm_trigger_template_put,
        alarm_trigger_template_get,
        alarm_type_query,
        device_data_recipe_query,
        device_data_recipe_list_body,
        dict_query,
        device_type_query

    } from '../../api/api';

    export default {

        data() {

            const generateData = _ => {
                const data = [];
                let para = {};
                //NProgress.start();
                alarms_query_user(para).then((res) => {
                     this.begCode(res.code,res.message);
                    // this.total = res.data.totalCount;
                    if (res.code == 0) {
                        for (let i in res.data.list) {
                            data.push({
                                type: 1,
                                sid: res.data.list[i].id,
                                label: res.data.list[i].name + "(告警人)"
                            });
                        }
                    } else {
                        this.$router.push({
                            path: '/login'
                        });
                    }
                    //NProgress.done();
                });
                alarm_group_query(para).then((res) => {
                     this.begCode(res.code,res.message);
                    // this.total = res.data.totalCount;
                    if (res.code == 0) {
                        for (let i in res.data.list) {
                            data.push({
                                type: 2,
                                sid: res.data.list[i].id,
                                label: res.data.list[i].name + "(告警组)"
                            });
                        }
                    } else {
                        this.$router.push({
                            path: '/login'
                        });
                    }
                    //NProgress.done();
                });
                setTimeout(() => {
                    for (let i in data) {
                        data[i].key = i;
                    }
                    console.log(data)
                }, 300)
                return data;
            };
            return {
                unitlist: '',
                alaem_grade: '',
                alarmUserList: [], //告警组ID
                alarmUserLists: [], //告警人ID
                alarmTypeValue: '',
                userlist: generateData(),
                filters: {
                    name: ''
                },
                typelist: [],
                query: [],
                total: 0,
                page: 1,
                listLoading: false,
                sels: [], //列表选中列
                editFormVisible: false, //编辑界面是否显示
                editLoading: false,
                editFormRules: {
                    name: [{
                        required: true,
                        message: '请输入模板名称',
                        trigger: 'blur'
                    },{ min: 1, max: 20, message: '长度在 1 到 20 个字符', trigger: 'blur' }],
            
                    alarmTypeId: [{
                        required: true,
                        message: '必填',
                        trigger: 'blur'
                    }],
                    deviceDataRecipeId: [{
                        required: true,
                        message: '必填',
                        trigger: 'blur'
                    }],
                    deviceDataRecipeBodyId: [{
                        required: true,
                        message: '必填',
                        trigger: 'blur'
                    }],
                    level: [{
                        required: true,
                        message: '必填',
                        trigger: 'blur'
                    }],
                    deviceTypeId: [{
                        required: true,
                        message: '必填',
                        trigger: 'blur'
                    }],
                    register: [{
                        required: true,
                        message: '必填',
                        trigger: 'blur'
                    }],
                    triggerCondition: [{
                        required: true,
                        message: '必填',
                        trigger: 'blur'
                    }],
                    inputMin: [{
                        required: true,
                        message: '必填',
                        trigger: 'blur'
                    }],
                    inputMax: [{
                        required: true,
                        message: '必填',
                        trigger: 'blur'
                    }],
                    alarmMode: [{
                        required: true,
                        message: '必填',
                        trigger: 'blur'
                    }],
                    isSave: [{
                        required: true,
                        message: '必填',
                        trigger: 'blur'
                    }],
                    status: [{
                        required: true,
                        message: '必填',
                        trigger: 'blur'
                    }],
                    customContent: [{
                        required: true,
                        message: '必填',
                        trigger: 'blur'
                    }],
                    customContentNormal: [{
                        required: true,
                        message: '必填',
                        trigger: 'blur'
                    }],
                    remark: [{
                        required: true,
                        message: '必填',
                        trigger: 'blur'
                    }],


               
                },
                //编辑界面数据
                editForm: {
                    alarmTypeId: '',
                    name: '',
                    deviceDataRecipeId: '',
                    deviceDataRecipeBodyId: '',
                    level: '',
                    register: '',
                    triggerCondition: '',
                    inputMin: '',
                    inputMax: '',
                    alarmMode: '',
                    isSave: '',
                    status: '',
                    customContent: '',
                    customContentNormal: '',
                    remark: '',
                    alarmTriggerGroupList: [],
                    alarmUserList: [],
                    alarmUserLists: []
                },
                alarmtype: '',
                device_data: '',
                device_datalist: ''

            }


        },
        computed:{
            buttonColor(){
                return this.$store.state.buttonColor
            },
            titleColor(){
                return this.$store.state.titleColor
            },
            dialogTitleColor(){
                return this.$store.state.dialogTitleColor
            },
        },
        methods: {
            Condition() {
                console.log(this.editForm.triggerCondition);
                if (this.editForm.triggerCondition == 0 || this.editForm.triggerCondition == 4) {
                    this.editFormRules.inputMin = [{
                        required: true,
                        message: '必填',
                        trigger: 'blur'
                    }]
                    this.editFormRules.inputMax=[];
                } else if (this.editForm.triggerCondition == 1) {
                    this.editFormRules.inputMin=[];
                    this.editFormRules.inputMax = [{
                        required: true,
                        message: '必填',
                        trigger: 'blur'
                    }]
                } else if (this.editForm.triggerCondition == 2 || this.editForm.triggerCondition == 3) {
                    this.editFormRules.inputMax = [{
                        required: true,
                        message: '必填',
                        trigger: 'blur'
                    }]
                    this.editFormRules.inputMin = [{
                        required: true,
                        message: '必填',
                        trigger: 'blur'
                    }]
                }
            },
            indexMethod(index) {
                let num = (this.page - 1) * 10 + index + 1;
                return num;
            },
            //性别显示转换
            scade() {
                let para = {
                    deviceDataRecipeId: this.editForm.deviceDataRecipeId,
                };
                //NProgress.start();

                device_data_recipe_list_body(para).then((res) => {
                     this.begCode(res.code,res.message);
                    if (res.code == 0) {
                        this.device_datalist = res.data.list;
                    }
                    this.listLoading = false;
                    //NProgress.done();
                });
            },
            formatSex: function (row, column) {
                return row.sex == 1 ? '男' : row.sex == 0 ? '女' : '未知';
            },
            handleCurrentChange(val) {
                this.page = val;
                this.getUsers();
            },
            //获取菜单列表
            getUsers() {
                if (this.menubt.indexOf('/alarm_trigger_template/query') == -1) {
                    this.$message({
                        message: '您没有查询告警模板的权限',
                        type: 'warning'
                    });
                    return false;
                }
                let para = {
                    pageNo: this.page,
                    pageSize: 10,
                    name: this.filters.name
                };
                this.listLoading = true;
                //NProgress.start();
                alarm_trigger_template_query(para).then((res) => {
                     this.begCode(res.code,res.message);
                    this.total = res.data.totalCount;
                    if (res.code == 0) {
                        this.query = res.data.list;
                        this.page=res.data.pageNo;
                        
                    }

                    this.listLoading = false;
                    //NProgress.done();
                });
            },
            //删除
            handleDel: function (index, row) {

                this.$confirm('确认删除该模板吗?', '提示', {
                    type: 'warning'
                }).then(() => {
                    this.listLoading = true;
                    //NProgress.start();
                    let para = {
                        idList: [row.alarmTriggerId]
                    };
                    alarm_trigger_template_delete(para).then((res) => {
                        this.begCode(res.code, res.message);
                        this.listLoading = false;
                        if (res.code == 0) {

                            //NProgress.done();
                            this.$message({
                                message: '删除成功',
                                type: 'success'
                            });
                            this.getUsers();

                        }
                    });
                }).catch(() => {

                });
            },
            //显示编辑界面
            handleEdit: function (index, row) {

                this.editFormVisible = true;

                let para = {
                    id: row.alarmTriggerId
                }
                alarm_trigger_template_get(para).then((res) => {
                     this.begCode(res.code,res.message);
                    // this.total = res.data.totalCount;
                    if (res.code == 0) {

                        this.editForm = Object.assign({}, res.data);
                        this.editForm.isSave = this.editForm.isSave.toString();
                        this.editForm.status = this.editForm.status.toString();
                        this.editForm.level = this.editForm.level.toString();
                        this.alarmUserList = [];
                        this.alarmUserLists = [];
                        for (let j in this.userlist) {

                            for (let i in res.data.triggerGroupList) {

                                console.log(res.data.triggerGroupList)
                                if (res.data.triggerGroupList[i].type == this.userlist[j].type && res.data.triggerGroupList[
                                        i].alarmTypeValue == this.userlist[j].sid) {

                                    this.alarmUserList.push(j);
                                    console.log(this.alarmUserList)

                                }
                            }

                        }
                        console.log(this.editForm)
                        this.Condition()
                        this.scade();
                    } else {
                        this.$router.push({
                            path: '/login'
                        });
                    }
                    //NProgress.done();
                });

            },
            //显示新增界面
            handleAdd: function () {

                this.addFormVisible = true;
                this.addForm = {
                    alarmTypeId: '',
                    name: '',
                    deviceDataRecipeId: '',
                    deviceDataRecipeBodyId: '',
                    level: '',
                    register: '',
                    triggerCondition: '',
                    inputMin: '',
                    inputMax: '',
                    alarmMode: '',
                    isSave: '',
                    status: '',
                    customContent: '',
                    customContentNormal: '',
                    remark: '',
                    alarmTriggerGroupList: {
                        type: '1',
                        alarmTypeValue: '1'
                    },
                };
            },
            //编辑
            editSubmit: function () {
                this.$refs.editForm.validate((valid) => {
                    if (valid) {
                        this.$confirm('确认提交吗？', '提示', {}).then(() => {
                            this.editForm.alarmTriggerGroupList = [];
                            for (let i in this.userlist) {
                                for (let j in this.alarmUserList) {
                                    if (this.alarmUserList[j] == i) {
                                        if (this.userlist[i].type == 1) {
                                            this.editForm.alarmTriggerGroupList.push({
                                                "type": 1,
                                                "alarmTypeValue": this.userlist[i].sid
                                            });
                                        } else {
                                            this.editForm.alarmTriggerGroupList.push({
                                                "type": 2,
                                                "alarmTypeValue": this.userlist[i].sid
                                            });
                                        }

                                        console.log(this.editForm.alarmTriggerGroupList)
                                    }
                                }
                            }
                            this.editLoading = true;
                            //NProgress.start();
                            let para = Object.assign({}, this.editForm);

                            alarm_trigger_template_put(para).then((res) => {
                                 this.begCode(res.code,res.message);

                                if (res.code == 0) {
                                    this.editLoading = false;
                                    //NProgress.done();
                                    this.$message({
                                        message: '提交成功',
                                        type: 'success'
                                    });
                                    this.$refs['editForm'].resetFields();
                                    this.editFormVisible = false;
                                    this.getUsers();
                                }
                            });
                        });
                    }
                });
            },
            //新增

            selsChange: function (sels) {
                this.sels = sels;
            },
            //批量删除
            batchRemove: function () {

                var ids = this.sels.map(item => item.alarmTriggerId).toString();
                this.$confirm('确认删除选中记录吗？', '提示', {
                    type: 'warning'
                }).then(() => {
                    this.listLoading = true;
                    //NProgress.start();
                    let para = {
                        idList: ids.split(',')
                    };
                    alarm_trigger_template_delete(para).then((res) => {
                        this.begCode(res.code, res.message);
                        this.listLoading = false;
                        //NProgress.done();
                        if (res.code == 0) {

                            //NProgress.done();
                            this.$message({
                                message: '删除成功',
                                type: 'success'
                            });
                            this.getUsers();

                        }
                    });
                }).catch(() => {

                });
            },
            tableToExcel(index,row){
                // console.log(row)
                var jsonData = [
                    {
                    name:'',//告警名字
                    alarmTypeId:'',//告警类型
                    deviceTypeId:'',//设备类型
                    level:'',//告警等级
                    triggerCondition:'',//触发条件
                    inputMin:'',//触发A值
                    inputMax:'',//触发B值
                    alarmMode:'',//告警方式
                    customContent:'',//告警推送内容
                    customContentNormal:'',//恢复正常推送内容
                    remark:'',//备注
                }];
                let para = {
                    id: row.alarmTriggerId
                }
                alarm_trigger_template_get(para).then((res) => {                  
                    console.log(res)
                    jsonData[0].name = res.data.name                                   
                    jsonData[0].triggerCondition = res.data.triggerCondition
                    jsonData[0].inputMin = res.data.inputMin
                    jsonData[0].inputMax = res.data.inputMax
                    // jsonData[0].alarmMode = res.data.alarmMode
                    jsonData[0].remark = res.data.remark
                    jsonData[0].customContent = res.data.customContent
                    jsonData[0].customContentNormal = res.data.customContentNormal

                    if(res.data.alarmMode == 1){
                        jsonData[0].alarmMode = '微信'
                    }else if(res.data.alarmMode == 2){
                        jsonData[0].alarmMode = '短信'
                    }else{
                        jsonData[0].alarmMode = '邮件'
                    }
                    let alarmType = this.alarmtype.find((item) => {
                        return item.id = res.data.alarmTypeId
                    })
                    jsonData[0].alarmTypeId = alarmType.name

                    let deviceType = this.typelist.find((item) => {
                        return item.id = res.data.deviceTypeId
                    })
                     jsonData[0].deviceTypeId = deviceType.name

                    let levelname = this.alaem_grade.find((item) => {
                        return item.id = res.data.level
                    })
                     jsonData[0].level = levelname.remark

                     let trigger = this.unitlist.find((item) => {
                        return item.id = res.data.triggerCondition
                    })
                     jsonData[0].triggerCondition = trigger.remark
                    // console.log(jsonData)

                    //列标题，逗号隔开，每一个逗号就是隔开一个单元格
                    let str = `告警名字,告警类型,设备类型,告警等级,触发条件,触发A值,触发B值,告警方式,告警推送内容,恢复正常推送内容,备注\n`;
                    //增加\t为了不让表格显示科学计数法或者其他格式
                    for(let i = 0 ; i < jsonData.length ; i++ ){
                        for(let item in jsonData[i]){
                            str+=`${jsonData[i][item] + '\t'},`;     
                        }
                        str+='\n';
                    }
                    //encodeURIComponent解决中文乱码
                    let uri = 'data:text/csv;charset=utf-8,\ufeff' + encodeURIComponent(str);
                    //通过创建a标签实现
                    let link = document.createElement("a");
                    link.href = uri;
                    //对下载的文件命名
                    link.download =  res.data.name + ".csv";
                    document.body.appendChild(link);
                    link.click();
                    document.body.removeChild(link);

                    //   var str =
                    // '<tr><td>告警名字</td><td>告警类型</td><td>设备类型</td><td>告警等级</td><td>触发条件</td><td>触发A值</td><td>触发B值</td><td>告警方式</td><td>告警推送内容</td><td>恢复正常推送内容</td><td>备注</td></tr>'
                     
                    // //Worksheet名
                    // for (let i = 0; i < jsonData.length; i++) {
                    //     str += '<tr>';
                    //     for (let item in jsonData[i]) {
                    //         //增加\t为了不让表格显示科学计数法或者其他格式
                    //         str += `<td>${ jsonData[i][item] + '\t'}</td>`;
                    //     }
                    //     str += '</tr>';
                    // }
                    // var worksheet = 'Sheet1'
                    // var uri = 'data:application/vnd.ms-excel;base64,';
                    // //下载的表格模板数据
                    // var template =
                    // `<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">     
                    // <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
                    // <head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet>
                    // <x:Name>${worksheet}</x:Name>
                    // <x:Name>${worksheet}</x:Name>
                    // <x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet>
                    // </x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]-->
                    // </head><body><table>${str}</table></body></html>`;
                    // //下载模板
                    // window.location.href = uri + this.base64(template)

                })
       
                             
            },//导出模板
             base64(s) {
                return window.btoa(unescape(encodeURIComponent(s)))
            },
        },
        mounted() {
            this.menubt = localStorage.getItem('menubt');
            this.getUsers();
            let para = {
                pageNo: 1,
                pageSize: 9999,
            };
            let para2 = {
                name: 'alarmLevel',
                pageSize: 999,
                pageNo: 1,
            }
            let para1 = {
                name: 'triggerCondition',
                pageSize: 999,
                pageNo: 1,
            }
            dict_query(para1).then((res) => {
                 this.begCode(res.code,res.message);
                if (res.code == 0) {
                    this.addLoading = false;

                    this.unitlist = res.data.list;


                }

            });
            dict_query(para2).then((res) => {
                 this.begCode(res.code,res.message);
                if (res.code == 0) {
                    this.addLoading = false;

                    this.alaem_grade = res.data.list;


                }

            });
            this.listLoading = true;
            //NProgress.start();
            alarm_type_query(para).then((res) => {
                 this.begCode(res.code,res.message);
                // this.total = res.data.totalCount;
                if (res.code == 0) {
                    this.alarmtype = res.data.list;
                }
                this.listLoading = false;
                //NProgress.done();
            });
            device_type_query(para).then((res) => {
                 this.begCode(res.code,res.message);

                this.addLoading = false;
                if (res.code == 0) {
                    this.typelist = res.data.list;
                } else {
                    this.$message({
                        message: res.message,
                        type: 'warning'
                    });
                }

            });
            device_data_recipe_query(para).then((res) => {
                 this.begCode(res.code,res.message);
                // this.total = res.data.totalCount;
                if (res.code == 0) {
                    this.device_data = res.data.list;
                }
                this.listLoading = false;
                //NProgress.done();
            });
        }
    }
</script>

<style scoped>

</style>